package com.cssw.fyzb.core.dao.video;

import com.cssw.fyzb.core.model.dodb.CmfUserVideoLike;
import com.ydn.dbframe.plugin.activerecord.Db;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @author YangYiQun
 */
@Repository
public class UserVideoLikeDaoImpl implements UserVideoLikeDao {

    @Override
    public CmfUserVideoLike findById(Long id) {
        return CmfUserVideoLike.dao.findById(id);
    }

    @Override
    public CmfUserVideoLike findById(Long userId, Long videoId) {
        String sql = "select * from cmf_user_video_like where user_id = ? and video_id = ?";
        return CmfUserVideoLike.dao.findFirst(sql, userId, videoId);
    }

    @Override
    public Long add(Long userId, Long videoId, Date likeTime) {
//        CmfUserVideoLike old = findById(userId, videoId);
//        if (null != old){
//            return old.getId();
//        }
//        CmfUserVideoLike userVideoLike = new CmfUserVideoLike();
//        userVideoLike.setUserId(userId);
//        userVideoLike.setVideoId(videoId);
//        userVideoLike.setCreateTime(likeTime);
//        userVideoLike.save();
//        return userVideoLike.getId();
        return null;
    }

    @Override
    public void delete(Long userId, Long videoId) {
        String sql = "delete from cmf_user_video_like where user_id = ? and video_id = ?";
        Db.delete(sql, userId, videoId);
    }
}
